﻿using DreamStore.WebShop.Models;
using JetBrains.Annotations;
using Orchard.ContentManagement;
using Orchard.ContentManagement.Handlers;
using Orchard.Data;
using Orchard.Localization;

namespace DreamStore.WebShop.Handlers
{
    [UsedImplicitly]
    public class PayPalApiSettingsPartHandler : ContentHandler
    {
        public Localizer T { get; set; }

        public PayPalApiSettingsPartHandler(IRepository<PayPalApiSettingsPartRecord> repository)
        {
            T = NullLocalizer.Instance;

            Filters.Add(new ActivatingFilter<PayPalApiSettingsPart>("Site"));
            Filters.Add(StorageFilter.For(repository));
        }

        protected override void GetItemMetadata(GetContentItemMetadataContext context)
        {
            if (context.ContentItem.ContentType != "Site")
                return;
            base.GetItemMetadata(context);
            context.Metadata.EditorGroupInfo.Add(new GroupInfo(T("PayPal")));
        }
    }
}